/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmlrpc.server;

import xmlrpc.client.Calculate_interface;
import java.io.IOException;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.webserver.WebServer;

/**
 *
 * @author martin
 */
public class Calculate implements Calculate_interface {
  @Override
  public Integer add(Integer a, Integer b){
    System.out.println(a+"+"+b);
    return new Integer(a+b);
  }
  
  
  public static void main (String [] args) throws IOException, XmlRpcException {

       System.out.println("Attempting to start XML-RPC Server...");
       //internal server
       WebServer server = new WebServer(8088);
       XmlRpcServer xmlRpcServer = server.getXmlRpcServer();

       
          PropertyHandlerMapping phm = new PropertyHandlerMapping();

          phm.addHandler("sample", Calculate.class);


       xmlRpcServer.setHandlerMapping(phm);
       server.start();
  }
}
